<template>
	<view class="contain">
		<view class="imglist flex flex-wrap">
			 <view v-for="(item,index) in datasArr.data" @click="previewImage(index)">
				 <!-- aspectFit -->
				 <view class="itemBox"><image :src="item" mode="heightFix"></image></view>
			 </view>
		</view>
	</view>
</template>

<script setup lang='ts'>
import { ref,reactive } from 'vue'
import {  onLoad } from '@dcloudio/uni-app'

let datasArr:Array<String>=reactive({data:[]});


onLoad(()=>{
	if(uni.getStorageSync("dataPhotos")){
		datas.value=uni.getStorageSync("dataPhotos");
		console.log("获取到数据:",datas.value);
		uni.setNavigationBarTitle({
			title: datas.value.classname+"/"+datas.value.coursename
		});
		datasArr.data=converArray(datas.value.imgphotos);
	}
	
});

const converArray=(ArrString:string)=>{
		let temp=ArrString.replace("[","").replace("]","");
		console.log("转换数据:",temp)
		//temp="[https://yulistudio.oss-cn-shenzhen.aliyuncs.com/images/fengcai/hslogo3861401706810798017.png]";  //测试单个数值
		if(temp.indexOf(",")!=-1){
			datasArr.data=temp.split(",");
		}else{
			datasArr.data.push(temp);
		}
		console.log("显示数组",datasArr.data);
		return datasArr.data;		
}

const datas=ref(null);

const previewImage=(index:number)=>{
	uni.previewImage({
		urls: datasArr.data,
		current: datasArr.data[index]
	});		
}

</script>

<style lang='scss' scoped>
	@import "lookdetail.scss";
</style>